<template>
  <view class="selectStore">
    <view class="list_item" v-for="(item,index) in listData" :key="index" @tap="selectItem(index)">
      <image :src="item.image[0]" class="item_img"></image>
      <view class="item_title">{{item.name}}</view>
    </view>
  </view>
</template>

<script>
import Taro from '@tarojs/taro'
import './selectStore.module.scss'
import LoginAPI from '../../api/login.js'
export default {
  name: 'selectStore',
  data(){
    return{
      listData: [],
    }
  },
  mounted(){
    this.getList();
  },
  methods:{
    async getList(){
      const res = await LoginAPI.selectRoom(Taro.getStorageSync('app_id'))
      this.listData = res.data;
    },
    selectItem(index){
      console.log(index)
      var data = this.listData[index];
      console.log(data)
      Taro.setStorageSync('store_id',data.id);
      Taro.setStorageSync('store_name',data.name);
      Taro.setStorageSync('store_image',data.image);

      Taro.switchTab({
        url: '/pages/home/home'
      })
    }
  },
}
</script>